package com.cjh.mybatis09.type;

import com.cjh.mybatis09.session.Configuration;
import lombok.Setter;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @Descripton 类型处理器的基类
 * @Author cjh
 * @Date 2023/6/26 15:35
 */
public abstract class BaseTypeHandler<T> implements TypeHandler<T> {
    @Setter
    protected Configuration configuration;

    @Override
    public void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
//        定义抽象方法 由子类实现不同类型的属性设置
        setNonNullParameter(ps,i,parameter,jdbcType);
    }
    protected abstract void setNonNullParameter(PreparedStatement ps,int i,T parameter,
                                           JdbcType jdbcType)throws SQLException;
}
